{php include wl_template('common/header');}
<script type="text/javascript" src="{URL_WEB_JS}diyarea.js"></script>
<style>
    #memberInfo .form-group{
        margin-bottom: 10px!important;
    }
    #memberInfo .img-photo{
        max-width: 150px;
        max-height: 150px;
        float:left;
        margin:2px;
    }
    #memberInfo video{
        height: 300px!important;
        width: auto!important;
        border: 1px solid #ddd;
        padding: 5px;
    }
    .margin-r-5{
        margin-right: 5px;
    }
</style>
<ul class="nav nav-tabs" id="myTab">
    <li class="active"><a href="#tab_basic">基础信息</a></li>
    <li><a href="#tab_contact">建面价格</a></li>
    <li><a href="#tab_requirement">企业信息</a></li>
    <li><a href="#tab_model">房型设置</a></li>
    <li><a href="#tab_personality">图片设置</a></li>
    <li><a href="#tab_other">分享设置</a></li>
</ul>
<div class="app-content">
    <div class="app-form" id="memberInfo">
        <form class="form-horizontal form form-validate" method="post">
            <div class="tab-content">
                <!-- 基本信息 -->
                <div class="tab-pane active" id="tab_basic">
                    <div class="panel panel-default">
                        <div class="panel-heading">基本信息</div>
                        <div class="panel-body">

                            <div class="form-group">
                                <label class="col-sm-2 control-label">小区<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <select name="info[apartment_id]" class="form-control" id="oneID">
                                        {loop $allgroup $groups}
                                        <option value="{$groups['id']}" {if $info['apartment_id'] == $groups['id']}selected{/if}>{$groups['name']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">楼盘名称<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <input class="form-control" required type="text" name="info[title]" value="{$info['title']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">咨询电话</label>
                                <div class="col-sm-9">
                                    <input class="form-control"  type="number" min="0"  name="info[mobile]" value="{$info['mobile']}"  />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">封面图片<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    {php echo attachment_select('info[cover_image]', $info['cover_image'])}
                                    <!--<span class="help-block">服务项目缩略图，建议使用正方形图片</span>-->
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">视频</label>
                                <div class="col-sm-9">
                                    {php echo attachment_select_video('info[cover_video]',$info['cover_video']);}
                                    <!--<div class="help-block">动态、图片、视频至少需要存在一项</div>-->
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">全景链接</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="text" name="info[panorama]" value="{$info['panorama']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">开盘时间<span class="must-fill">*</span></label>
                                <div class="col-sm-9">
                                    {php echo tpl_form_field_date('info[start_time]',$info['start_time'])}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">交付时间<span class="must-fill">*</span></label>
                                <div class="col-sm-9">
                                    {php echo tpl_form_field_date('info[delivery_time]',$info['delivery_time'])}
                                </div>
                            </div>
                            {if !is_store()}
                            <div class="form-group">
                                <label class="col-sm-2 control-label">所属商户</label>
                                <div class="col-sm-9">
                                    <div class='input-group'>
                                        <div class="input-group ">
                                            <input type="text" class="form-control col-sm-9" id="namemerchant" name="" value="{$shop['storename']}" style="width: 460px;" disabled>
                                            <span class="input-group-btn">
                                            <button class="btn btn-default" type="button" onclick="popwin = $('#modal-module-merchant').modal();">选择商家</button></span>
                                        </div>
                                        <div class="input-group " style="margin-top:.5em;">
                                            <input type="hidden" value="{$info['shop_id']}" name="info[shop_id]" id="sidmerchant" >
                                            <img src="{if empty($shop['logo'])}../web/resource/images/nopic.jpg{else}{php echo tomedia($shop['logo'])}{/if}" class="img-responsive img-thumbnail" width="150" id="imgmerchant" />
                                            <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除" onclick="remove_merchant(this)">×</em>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {/if}
                            <div class="form-group">
                                <label class="col-sm-2 control-label">建筑类型</label>
                                <div class="col-sm-9">
                                    <select name="info[house_type]" class="form-control">
                                        {loop $house_type_arr $v}
                                        <option value="{$v['id']}" {if $info['house_type'] == $v['id']}selected{/if}>{$v['title']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">装修状态</label>
                                <div class="col-sm-9">
                                    <select name="info[decoration_id]" class="form-control" >
                                        {loop $decoration $children}
                                        <option value="{$children['id']}" {if $children['id'] == $info['decoration_id']}selected{/if}>{$children['title']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">新房标签</label>
                                <div class="col-sm-9">
                                    <!--<select name="info[new_ids][]" class="form-control select2" multiple>-->
                                        <!--<optgroup label="新房标签">-->
                                            <!--{loop $new_label $children}-->
                                            <!--<option value="{$children['id']}" {if in_array($children['id'], explode(',',$info['new_ids']))}selected{/if}>{$children['title']}</option>-->
                                            <!--{/loop}-->
                                        <!--</optgroup>-->
                                    <!--</select>-->

                                    {loop $new_label $children}
                                    <label class="checkbox-inline">
                                        <input type="checkbox" value="{$children['id']}" name="info[new_ids][]"  {if in_array($children['id'],explode(',',$info['new_ids']))}checked="checked"{/if} /> {$children['title']}
                                    </label>
                                    {/loop}
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">产权年限(年)<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <input class="form-control" required type="number" min="0"  name="info[year]" value="{$info['year']}"  />
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">使用年限</label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <input type="number" min="0" name="info[use_year]" class="form-control" value="{$info['use_year']}" />
                                        <span class="input-group-addon">年</span>
                                    </div>
                                    <!--<span class="help-block">购买数量上限,如果不填或者填0，则默认为“不限制购买数量”。</span>-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">状态</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="info[status]" value="1" {if $info['status']==1}checked{/if}> 销售中
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[status]" value="2" {if $info['status']==2}checked{/if}> 已下架
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[status]" value="4" {if $info['status']==4}checked{/if}> 待审核
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[status]" value="5" {if $info['status']==4}checked{/if}> 被驳回
                                    </label>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">热门</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="info[hot_status]" value="1" {if $info['hot_status']==1}checked{/if}> 是
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[hot_status]" value="2" {if $info['hot_status']==2}checked{/if}> 否
                                    </label>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">电梯</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="info[elevator]" value="1" {if $info['elevator']==1}checked{/if}> 有
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[elevator]" value="2" {if $info['elevator']==2}checked{/if}> 无
                                    </label>
                                </div>
                            </div>



                            <div class="form-group">
                                <label class="col-sm-2 control-label">当前所在城市</label>
                                <div class="col-sm-9">
                                    <div class="row row-fix js-address-selector selectArea">
                                        <div class="col-md-3" id="tpl-province">
                                            <select name="info[current_province]" data-value="{$info['current_province']}" level="1" class="form-control tpl-province changeArea">
                                                {loop $province $item}
                                                <option value="{$item['id']}" {if $item['id'] == $info['current_province']}selected="selected"{/if}>{$item['name']}</option>
                                                {/loop}
                                            </select>
                                        </div>
                                        <div class="col-md-3" id="tpl-city">
                                            <select name="info[current_city]" data-value="{$info['current_city']}" level="2"  class="form-control tpl-city changeArea">
                                                {loop $city $item}
                                                <option value="{$item['id']}" {if $item['id'] == $info['current_city']}selected="selected"{/if}>{$item['name']}</option>
                                                {/loop}
                                            </select>
                                        </div>
                                        <div class="col-md-3"  id="tpl-district">
                                            <select name="info[current_area]" data-value="{$info['current_area']}" level="3"  class="form-control tpl-district changeArea">
                                                {loop $district $item}
                                                <option value="{$item['id']}" {if $item['id'] == $info['current_area']}selected="selected"{/if}>{$item['name']}</option>
                                                {/loop}
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">详细地址<span class="must-fill">*</span></label>
                                <div class="col-sm-9">
                                    {php echo tpl_select_address('info[address]','info[lng]','info[lat]',$info['address'],$info['lng'],$info['lat'])}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">楼盘介绍<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    {php echo tpl_diy_editor_create('info[describe]', $info['describe']);}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序</label>
                                <div class="col-sm-9">
                                    <input class="form-control"  type="number" min="0"  name="info[weigh]" value="{$info['weigh']}"  />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 价格设置 -->
                <div class="tab-pane" id="tab_contact">
                    <div class="panel panel-default">
                        <div class="panel-heading">建面价格</div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">均价(元/㎡)<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <input class="form-control" required type="number" min="0"  name="info[average_price]" value="{$info['average_price']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">最低价(元/㎡)<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <input class="form-control" required type="number" min="0"  name="info[min_price]" value="{$info['min_price']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">最高价(元/㎡)<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <input class="form-control" required type="number" min="0"  name="info[max_price]" value="{$info['max_price']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">最小户型面积(㎡)<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <input class="form-control" required type="number" min="0"  name="info[architecture_size]" value="{$info['architecture_size']}"  />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">最大户型面积(㎡)<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <input class="form-control" required type="number" min="0"  name="info[architecture_max_size]" value="{$info['architecture_max_size']}"  />
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

                <!-- 其他设置 -->
                <div class="tab-pane" id="tab_requirement">
                    <div class="panel panel-default">
                        <div class="panel-heading">企业信息</div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">开发商</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="text" name="info[developers]" value="{$info['developers']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">投资商</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="text" name="info[investor]" value="{$info['investor']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">品牌商</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="text" name="info[brand_dealer]" value="{$info['brand_dealer']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">代理商</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="text" name="info[agent_company]" value="{$info['agent_company']}"  />
                                </div>
                            </div>



                        </div>
                    </div>
                </div>

                <!-- 房型设置 -->
                <div class="tab-pane" id="tab_model">
                    <div class="panel panel-default">
                        <div class="panel-heading">房型设置</div>
                        <div class="panel-body">

                            <div class="form-group">
                                <label class="col-sm-2 control-label">发布房型</label>
                                <div class="col-sm-9">
                                    <div id="datas">
                                        {if empty($_modelInfo)}
                                        {php $j=0}
                                        {php $cover_image_key='modelInfo[0][cover_image]'}
                                        {php include wl_template('newhouse/housemodel');}
                                        {else}
                                        {loop $_modelInfo $j=>$modelInfo}
                                        {php $cover_image_key='modelInfo['.$j.'][cover_image]'}
                                        {php include wl_template('newhouse/housemodel');}
                                        {/loop}
                                        {/if}
                                        <input id="kw" type="text" hidden value="{$j}">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"></label>
                                <div class="col-sm-9">
                                    <a class="btn btn-info btn-add-type" href="javascript:;" onclick="addType();">
                                        <i class="fa fa-plus" title=""></i>增加一个房型
                                    </a>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

                <!-- 图片设置 -->
                <div class="tab-pane" id="tab_personality">
                    <div class="panel panel-default">
                        <div class="panel-heading">图片设置</div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">配套图<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    {php echo attachment_select_multi('info[matching_images]',$info['matching_images']);}
                                    <!--<span class="help-block">服务项目缩略图，建议使用正方形图片</span>-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">规划图</label>
                                <div class="col-sm-9">
                                    {php echo attachment_select_multi('info[plan_images]',$info['plan_images']);}
                                    <!--<span class="help-block">服务项目缩略图，建议使用正方形图片</span>-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">外景图片</label>
                                <div class="col-sm-9">
                                    {php echo attachment_select_multi('info[outdoor_scene_images]',$info['outdoor_scene_images']);}
                                    <!--<span class="help-block">服务项目缩略图，建议使用正方形图片</span>-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">沙盘图</label>
                                <div class="col-sm-9">
                                    {php echo attachment_select_multi('info[sand_table_images]',$info['sand_table_images']);}
                                    <!--<span class="help-block">服务项目缩略图，建议使用正方形图片</span>-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">样板间</label>
                                <div class="col-sm-9">
                                    {php echo attachment_select_multi('info[example_images]',$info['example_images']);}
                                    <!--<span class="help-block">服务项目缩略图，建议使用正方形图片</span>-->
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

                <!-- 分享设置 -->
                <div class="tab-pane" id="tab_other">
                    <div class="panel panel-default">
                        <div class="panel-heading">分享设置</div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分享标题</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="text" name="info[share_title]" value="{$info['share_title']}"  />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">分享图片</label>
                                <div class="col-sm-9">
                                    {php echo attachment_select('info[share_logo]', $info['share_logo'])}
                                    <span class="help-block">推荐图片比例：100*100</span>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">分享描述</label>
                                <div class="col-sm-9">
                                    <textarea class="form-control" name="info[share_describe]"  style="resize: none;height: 150px;">{$info['share_describe']}</textarea>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>


            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-9">
                    <input type="submit" name="submit" value="提交" class="btn btn-primary min-width" />
                    <input type="hidden" name="token" value="{$_W['token']}" />
                    <input type="hidden" name="id" value="{$_GPC['id']}" />

                    <a href="{php echo web_url('house/House/newHouseList')}" class="btn btn-danger min-width margin-r-5">返回</a>
                </div>
            </div>
            <div id="modal-module-merchant" class="modal fade" tabindex="-1">
                <div class="modal-dialog" style='width: 920px;'>
                    <div class="modal-content">
                        <div class="modal-header">
                            <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                            <h3>选取</h3></div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="input-group">
                                    <input type="text" class="form-control" name="keyword" value="" id="search-kwd-merchant" placeholder="请输入商家名称，不输入任何内容搜索结果为所有商家。" />
                                    <span class='input-group-btn'><button type="button" class="btn btn-default" onclick="search_merchant();">搜索</button></span>
                                </div>
                            </div>
                            <div id="module-merchant" style="padding-top:5px;"></div>
                        </div>
                        <div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a></div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    // $(function() {
    //     window.optionchanged = false;
    //     $('#myTab a').click(function(e) {
    //         e.preventDefault(); //阻止a链接的跳转行为
    //         $(this).tab('show'); //显示当前选中的链接及关联的content
    //     })
    // });
    var kw = parseInt($("#kw").val()) + 1;
    function addType() {
        // $(".btn-add-type").button("loading");
        $.ajax({
            url: "{php echo web_url('house/House/housemodel')}&kw="+kw,
            cache: false
        }).done(function (html) {
            // $(".btn-add-type").button("reset");
            $("#datas").append(html);
        });
        kw++;
    }
    function removes(asd){
        $(asd).closest('.data-item').remove();
    }

    function search_merchant() {
        $("#module-merchant").html("正在搜索....")
        $.get("{php echo web_url('house/House/selectMerchant')}", {
            keyword: $.trim($('#search-kwd-merchant').val())
        }, function(dat){
            $('#module-merchant').html(dat);
        });
    }
    function remove_merchant(obj){
        $('#goodsidmerchant').val('');
        $('#namemerchant').val('');
        $('#imgmerchant').attr("src",'');
        $('#sidmerchant').val('');
    }
    function select_merchant(o) {
        var lastid = $('#sidmerchant').val();
        if (lastid != o.id) {
            $('#sidmerchant').val(o.id);
            $('#namemerchant').val(o.storename);
            $('#imgmerchant').attr("src",o.logo);
            $('#modal-module-merchant').modal('hide');
            inspect();
        }else{
            $('#modal-module-merchant').modal('hide');
        }
    }

</script>
{php include wl_template('common/footer');}
